<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<script type="text/javascript">
function changeAsset() {
	var ids = '';
	var count = 0;
	var state = '';
	$('input:checkbox[name="ids"]:checked',navTab.getCurrentPanel()).each(function(i, n) {
		ids = n.value;
		count += count+1;
		state = $(this).attr("state");
	});
	if(count == 0) {
		alert('请选择你要修改的信息！');
		return ;
	}
	else if(count > 1) {
		alert('只能选择一条信息进行修改！');
		return ;		
	}
	else {
		if(state=='1010101'){
		 	var navTabId = navTab._getTabs().filter('.selected').attr('tabid');
			navTab.openTab("listasset", "../asset/assetAction!modifyAssetAll.action?id="+ids+"&navTabId="+navTabId, { title:"修改", fresh:false, data:{} });
	}else{
		alert("只有未派发的资产才能修改！");
		return;
	}
	}
}
	/* function deleteAsset(){
			var state = '';
			$('input:checkbox[name="ids"]:checked',navTab.getCurrentPanel()).each(function(i, n) {
				state = $(this).attr("state");
			});
				if(state=='1010101'){
					this.attr("href","${path }/asset/assetAction!deleteAsset.action");
					this.attr("rel","ids");
					this.attr("postType","string");
					this.attr("title","确定要删除吗?");
					this.attr("target","selectedTodo");
					return true;
			}else{
				alert("只有入库的资产才能删除！");
				return false;
			}
	} */
/* function setTimeTo1(value){
	$("#filter_and_yearAndMonth1_LE_T").val(value) ;
}
function getLastDay(year,month) {  
 var new_year = year;    //取当前的年份
 var new_month = month++;//取下一个月的第一天，方便计算（最后一天不固定）
 if(month>12)            //如果当前大于12月，则年份转到下一年  
{  
  new_month -=12;        //月份减  
  new_year++;            //年份增  
 }  
 var new_date = new Date(new_year,new_month,1);                //取当年当月中的第一天  
 return (new Date(new_date.getTime()-1000*60*60*24)).getDate();//获取当月最后一天日期  
}  
 */
</script>
<div class="tip"><span>查询</span></div>
<div class="pageHeader">
	<form onsubmit="if(this.action != '${path }/asset/assetAction!listAsset.action'){this.action = '${path }/asset/assetAction!listAsset.action' ;} ;return navTabSearch(this);" action="${ path }/asset/assetAction!listAsset.action" method="post" rel = "pagerForm" id="pagerFindForm">
	<div class="searchBar">
		<table class="pageFormContent">
				 <tr>
				  <td>
					<label>名称：</label><input type="text" name="filter_and_name_LIKE_S" value="${filter_and_name_LIKE_S }"/>
				</td>
				 <td>
					<label>型号：</label><input type="text" name="filter_and_models_LIKE_S" value="${filter_and_models_LIKE_S }"/>
				</td>
				<td>
					<label>类别：</label>
					<select name="filter_and_type_EQ_S"  rel="iselect" loadUrl="${path}/hpin/sysDictType!treeRegion.action?defaultID=10105">
						<option value="${ filter_and_type_EQ_S }"></option>	
					</select>
				</td>
				 </tr>
				 <tr>
				
				
				 <td>
				<label>启用日期：</label>
				<input type="text" name="filter_and_startusetime_GEST_T"  id="d1" style="width: 170px;" onFocus="WdatePicker({minDate:'2000-01-01',maxDate:'#F{$dp.$D(\'d2\')}'})"  readonly="readonly" value="${filter_and_assetstartusetime_GEST_T}" /><a class="inputDateButton" href="javascript:;" >选择</a>
			</td>
			<td>
				<label>至：</label>
				<input type="text" name="filter_and_startusetime_LEET_T" id="d2" style="width: 170px;" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'d1\')}'})"  readonly="readonly" value="${filter_and_startusetime_LEET_T}" /><a class="inputDateButton" href="javascript:;">选择</a>
			</td>
				
					<td>
					<div class="buttonActive"><div class="buttonContent"><button type="submit">查找</button></div></div>
					<div class="buttonActive"><div class="buttonContent"><button type="button" id="clearText">重置</button></div></div>
					</td>
				</tr>
		</table>
	</div>
	</form>
</div>
<div class="pageContent">
	<div class="panelBar">
	<web:security tag="assetAdmin">
		<ul class="toolBar">
			<li><a class="add" href="${path }/asset/assetAction!addAsset.action" target="navTab"><span>添加</span></a></li>
			<li><a class="delete" href="${path }/asset/assetAction!deleteAsset.action"  rel="ids" postType="string" title="确定要删除吗?" target="selectedTodo"><span>删除</span></a></li>
			<li><a class="edit" onclick="changeAsset()" style="cursor:pointer;"><span>修改</span></a></li>
			<li><a class="edit" href="${path }/asset/assetAction!returnAsset.action? rel="ids" postType="string" title="确定要归还吗?" target="selectedTodo"><span>归还</span></a></li>
			<web:exportExcelTag 
					pagerFormId="pagerFindForm" 
					pagerMethodName="findByPage" 
					actionAllUrl="org.hpin.asset.web.AssetAction" 
					informationTableId="exportExcelTable"
					fileName="asset"></web:exportExcelTag>
		</ul>
	</web:security>
		<jsp:include page="/common/pagination.jsp" />	
	</div>
	<table class="list" width="100%" layoutH="160" id="exportExcelTable">
		<thead>
			<tr>
				<th>序号</th>
				<th nowrap="nowrap" export = "true" columnEnName = "name" columnChName = "名称" >名称</th>
				<th nowrap="nowrap" export = "true" columnEnName = "models" columnChName = "型号" >型号</th>
				<th nowrap="nowrap" export = "true" columnEnName = "type" columnChName = "类别" id2NameBeanId = "org.hpin.base.dict.dao.SysDictTypeDao">类别</th>
		        <th nowrap="nowrap" export = "true" columnEnName = "startusetime" columnChName = "启用日期"  ><nobr><a href="javascript:navSort('order_startusetime','desc');">启用日期</a></nobr></th>
				<th nowrap="nowrap" export = "true" columnEnName = "state" columnChName = "状态" id2NameBeanId = "org.hpin.base.dict.dao.SysDictTypeDao">状态</th>
				<th nowrap="nowrap">操作</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${ page.results }" var="asset" varStatus="state">
			<tr target="sid_user" rel="${ asset.id }">
				<td align="center"><input type="checkbox" name="ids" value="${ asset.id }" state="${ asset.state }">${ state.count }</td>
				<td><a href="${ path }/asset/assetAction!browAssetAll.action?id=${ asset.id }" width="800" height="480" style="color:#0000FF" target="dialog" name="${asset.name }">${fn:substring(asset.name,0,18) }</a></td>
				<td  align="center" nowrap="nowrap">${asset.models}</td>
				<td  align="center" nowrap="nowrap"><hpin:id2nameDB  beanId="org.hpin.base.dict.dao.SysDictTypeDao" id="${asset.type}"/></td>
				<td  align="center" nowrap="nowrap"><fmt:formatDate value="${asset.startusetime}" pattern="yyyy-MM-dd" /></td>
				<td align="center" nowrap="nowrap"><hpin:id2nameDB  beanId="org.hpin.base.dict.dao.SysDictTypeDao" id="${asset.state}"/></td>
				<td align="center" nowrap="nowrap">
				 <web:security tag="assetAdmin">
				  <c:if test="${asset.state eq '1010102'||asset.state eq '1010106' }">
					<a href="${path }/asset/assetAction!upgradeAssetAll.action?id=${ asset.id }" target="navTab"><span style="color: green;">升级</span></a>
				  </c:if>
				 <c:if test="${asset.state eq '1010101'}">
				 	<a href="${path }/asset/assetAction!modifyAsset.action?id=${ asset.id }" target="navTab"><span>修改</span></a> | 
				 	<a href="${path }/asset/assetAction!distributedAsset.action?id=${ asset.id }" target="navTab"><span style="color: red;">派发</span></a> | 
				  	<a href="${path }/asset/assetAction!upgradeAssetAll.action?id=${ asset.id }" target="navTab"><span style="color: green;">升级</span></a>
				  </c:if>
				 </web:security> 
				</td>
				
				
		</c:forEach>
		</tbody>
	</table>
</div>
